Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix over-reading while de-serializing #107

Merged
merged 1 commit into from
Sep 7, 2022

Conversation

thanhpk
Copy link
Contributor

@thanhpk thanhpk commented Sep 7, 2022

The loop in the ReadFrom method has a wrong boundary condition. It should looping through word-length instead of bit-length.
If the input file has trailing data, it would over read and crash the program. See bits-and-blooms/bloom#85.

This pull request fix the problem and add a test case to prove its correctness.

bitset.go Outdated
if _, err := reader.Read(item); err != nil {
if err == io.EOF {
break // done
return 0, io.ErrUnexpectedEOF
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just remove this branch here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@lemire
Copy link
Member

lemire commented Sep 7, 2022

Please have a look at my comment. Can this code be even simpler ?

@lemire
Copy link
Member

lemire commented Sep 7, 2022

Merging.

@lemire lemire merged commit 36eb6b6 into bits-and-blooms:master Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants